// JavaScript Document

$(function(){
		   
	//经典案例切换效果
   $("div#casetype").tabs("div#caseCon > div.caselist", {
		event:'mouseover',
		tabs: 'div#casetype > a'
	})
   

	//图片播放器滚动效果
	//$("#panel").scrollable({circular: true, speed:1000}).navigator().autoscroll({
//	         interval: 4000
//      });

	//图片播放器
	$(document).ready(function(){           
	  autoroll();
	  hookThumb();
	});
	  var i=-1; //第i+1个tab开始
	  var offset = 5000; //轮换时间
	  var timer = null;
		  function autoroll(){
		  n = $('.navi a').length-1;
		  i++;
		  if(i > n){
		  i = 0;
		  }
	  slide(i);
	  timer = window.setTimeout(autoroll, offset);
	  }
function slide(i){
	  $('.navi a').eq(i).addClass('active').siblings().removeClass('active');
	  var wrapbg=$(".imgplayWrap");
	  if(i>0){
		$(wrapbg).attr("class","imgplayWrap imgplayWrap"+i);
	  }else if(i==0){  
		$(wrapbg).attr("class","imgplayWrap imgplayWrap0");
	  }
	  $('.showimg div.fl').eq(i).fadeIn("slow").siblings('div.fl').css('display','none');
	    

}
function hookThumb(){
	  $('.navi a').hover(
	  function () {
	  if (timer) {
	  clearTimeout(timer);
	  i = $(this).prevAll().length;
	  slide(i);
	  }
},
function () {

		timer = window.setTimeout(autoroll, offset);
		this.blur();
		return false;
		}
);
}


	
	//更多的tooltip
	$(".link a").tooltip();
   
   //公司动态滚动实现方法
    $.fn.extend({
		Scroll: function(opt, callback) {
            //参数初始化
            if (!opt) var opt = {};
			var self=this;
            var _upElem = this.eq(0).find("ul:first");
            var lineH = _upElem.find("li:first").height(),
            //获取行高
            line = opt.line ? parseInt(opt.line, 10) : parseInt(this.height() / lineH, 10),
            //每次滚动的行数，默认为一屏，即父容器高度
            speed = opt.speed ? parseInt(opt.speed, 10) : 500,
            //卷动速度，数值越大，速度越慢（毫秒）
            timer = opt.timer ? parseInt(opt.timer, 10) : 3000, 
			//滚动的时间间隔（毫秒）
			col = opt.col || 1,
			len=line*col;
            if (line == 0) line = 1;
            var upHeight = 0 - line * lineH;
            //滚动函数
            var scrollUp = function() {
				self.css('position','relative');
				_upElem.css('position','absolute');
                _upElem.animate(
					{top: upHeight},
					speed,
					function(){
						for (var i = 1; i <= len; i++) {
							_upElem.find("li:first").appendTo(_upElem);
						}
						_upElem.css({	top: 0});
                	}
				);
            }
			var timerID;
            //鼠标事件绑定
            _upElem.hover(function() {
                clearInterval(timerID);
            },
            function() {
                timerID = setInterval(scrollUp, timer);
            }).mouseout();
        }
    })
})

//公司动态
$(function(){
//$(document).ready(function() {
	$("#news").Scroll({
        line: 2,
        speed: 800,
        timer: 5000
    })
})


//友情链接滚动效果
function ScrollImgLeft(){ 
	var speed = 20; 
	var scroll_begin=document.getElementById("scroll_begin"); 
	var scroll_end=document.getElementById("scroll_end"); 
	var scroll_div=document.getElementById("scroll_div"); 
	scroll_end.innerHTML=scroll_begin.innerHTML; 
	function Marquee(){ 
		if(scroll_end.offsetWidth-scroll_div.scrollLeft<=0) 
		scroll_div.scrollLeft-=scroll_begin.offsetWidth ; 
	else 
		scroll_div.scrollLeft++ 
	} 
	var MyMar=setInterval(Marquee,speed); 
	scroll_div.onmouseover=function(){clearInterval(MyMar)} 
	scroll_div.onmouseout=function(){MyMar=setInterval(Marquee,speed)} 
} 

